package com.peanut.wapp.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.peanut.wapp.model.UserInfoBean;
import com.peanut.wapp.persist.UserDao;

@Repository
public class UserImpl extends BaseImpl implements UserDao {
	
	final String NAME_SPACE = NAME_SPACE_HEADER + ".UserMapper";

	@Override
	public UserInfoBean selectOneByPhone(String phone) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneByPhone", phone);
	}

	@Override
	public int insert(UserInfoBean user) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insert", user);
	}

	@Override
	public int selectCount() {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount");
	}

	@Override
	public List<UserInfoBean> selectList(int start, int pageSize) {
		Map<String, Object> where = new HashMap<>();
		where.put("start", start);
		where.put("length", pageSize);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", where);
	}

	@Override
	public int update(UserInfoBean user) {
		return sqlSessionTemplate.update(NAME_SPACE + ".update", user);
	}

	@Override
	public UserInfoBean selectOneById(String uid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectOneById", uid);
	}

}
